package main

import (
	"fmt"
	"sync"
	"time"
)

var wg2 sync.WaitGroup

func test2(startNum int, endNum int) {
	for i := startNum; i < endNum; i++ {
		if i%2 != 0 {
			fmt.Println(i, "是素数")
		}
	}
	wg2.Done()
}
func main() {

	start := time.Now().Unix()

	for i := 0; i <= 3; i++ {

		wg2.Add(1)

		if i == 0 {
			go test2(2, 30000*(i+1))
		} else {
			go test2(30000*i+1, 30000*(i+1))
		}

	}
	//go test2(2, 30000)
	//go test2(30001, 60000)
	//go test2(60001, 90000)
	//go test2(90001, 120000)

	wg2.Wait()

	fmt.Println("执行完毕")
	end := time.Now().Unix()

	fmt.Println(end-start, "毫秒")
}
